﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.ServiceModel;
using MagicEightBallServiceLib;

namespace MagicEightBallHost
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("*********** Magic EightBall Host ************");

            using (ServiceHost host = new ServiceHost(typeof (MagicEightBallService)))
            {
                host.Open();
                DisplayServiceHostInfo(host);

                Console.WriteLine("The service is open. Hit the Enter-key to close the service.");
                Console.ReadLine();
            }
        }

        static void DisplayServiceHostInfo(ServiceHost host)
        {
            Console.WriteLine("\n*********** HOST INFO ************");


            foreach (var endpoint in host.Description.Endpoints)
            {
                Console.WriteLine("Address: " + endpoint.Address);
                Console.WriteLine("Binding: " + endpoint.Binding.Name);
                Console.WriteLine("Contract: " + endpoint.Contract.Name);
            }
            
            Console.WriteLine("*****************************");
        }
    }
}
